package com.openget.lang;

import javax.lang.model.type.NullType;

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class TextElement extends ElementModel implements IFunctionElement<String, NullType> {

	public TextElement(Element source) {
		super(source);
	}

	@Override
	public String call(OpengetContext context, NullType nullType) {
		//context.getRunning().put("returnValue", "火影忍者第230话");
		Node element = this.getSourceElement();
		if (element.getNodeType() == org.w3c.dom.Node.TEXT_NODE)
			return element.getNodeValue();
		if (element.getNodeType() == org.w3c.dom.Node.CDATA_SECTION_NODE)
			return element.getFirstChild().getNodeValue();
		else
			return null;
	}

}
